package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbAddressMapper;
import com.dongdongshop.pojo.TbAddress;
import com.dongdongshop.service.AddressService;
import com.dongdongshop.vo.AddressVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@DubboService
public class AddressServiceImpl implements AddressService {

    @Resource
    private TbAddressMapper addressMapper;

    @Override
    public List<AddressVO> getAddressInfo(Long userId) {
        return addressMapper.getAddressInfo(userId);
    }

    @Override
    public int addAddress(TbAddress address) {
        address.setIsDefault("1");
        return addressMapper.insertSelective(address);
    }

    @Override
    public TbAddress echoAddress(Long id) {
        return addressMapper.selectByPrimaryKey(id);
    }

    @Override
    public int deleteId(Long id) {
        return addressMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateAddress(TbAddress address) {
        return addressMapper.updateByPrimaryKeySelective(address);
    }

    @Override
    public AddressVO getAddressVO(Long id) {
        return addressMapper.getAddressVO(id);
    }
}
